package cn.song.service.impl;

import cn.song.domain.ProductCategory;
import cn.song.repository.CategoryRepository;
import cn.song.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Resource
    private CategoryRepository categoryRepository;

    @Override
    public ProductCategory findone(Integer id) {
        return categoryRepository.findOne(id);
    }

    @Override
    public List<ProductCategory> findAll() {
        return categoryRepository.findAll();
    }

    @Override
    public List<ProductCategory> findProductCategoryByType(List<Integer> listType) {
        return categoryRepository.findByCategoryTypeIn(listType);
    }

    @Override
    public ProductCategory saveProductCategory(ProductCategory productCategory) {
        return categoryRepository.save(productCategory);
    }
}
